#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int g_val = 100;

int main()
{
    pid_t id = fork();
    if(id == 0){
        int i = 0;
        while (i < 5)
        {
           i++;
           sleep(1); 
           printf("child[%d]:  %d  :  %p  \n", getpid(), g_val, &g_val);
           if (i == 3) {
               printf("-----------------------------更改数据\n");
               g_val = 200;
               printf("-----------------------------完成更改\n");
           }
        }
    }
    else if (id > 0){
        int i = 0;
        while (i < 3)
        {
           sleep(1); 
            printf("parent[%d]:  %d  :  %p  \n", getpid(), g_val, &g_val);
        }
    }
    else {
        ;
    }

    return 0;
}
